<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>认识Jquery</title>
</head>
<style>
    div {
        border: 1px solid #ccc;
        width: 100px;
        height: 100px;
    }
</style>

<body>
    <div id="id1" class="div"></div>
    <div id="id2" class="div"></div>
    <div id="id3" class="div"></div>
    <script src="../LearnJquery/js/jquery-1.11.3.js"></script>
    <script type=text/javascript>
        // 原生js操作DOM 
        var div1 = document.getElementById("id1");
        var div2 = document.getElementsByTagName("div")[1];
        var div3 = document.getElementsByClassName("div")[2]; // 原生js设置盒子属性
        div1.style.backgroundColor = "yellow";
        div2.style.backgroundColor = "blue";
        div3.style.backgroundColor = "red";
        //--------------------------------------------- 
        $(function() { //JQuery入口函数 
            $div1 = $("#id1");
            $div2 = $(".div").eq(1);
            $div3 = $("div").eq(2); //不能使用$("div")[2] 
            console.log($div3);
            $div1.css({
                background: "red",
                width: "200px",
            });
            $div2.css({
                background: "yellow",
                width: "300px",
            });
            $div3.css({
                background: "green",
                width: "1000px",
            });
        })
    </script>
</body>

</html>